const path = require("path");
const fs = require("fs");
const util = require("util");

let Filepath1 = path.join(__dirname, "files", "我.txt");
let Filepath2 = path.join(__dirname, "files", "爱.txt");
let Filepath3 = path.join(__dirname, "files", "node.js.txt");

function FilePromise(Filepath) {
    return new Promise((resolve, reject) => {
        fs.readFile(Filepath, "utf-8", (error, data) => {
            if (error) {
                reject(error);
            }
            resolve(data);
        })
    })
}
let p1 = FilePromise(Filepath1);
let p2 = FilePromise(Filepath2);
let p3 = FilePromise(Filepath3);
let str = "";
p1.then((data) => {
    str += data;
    return p2;
}, (error) => {
    console.log(error);
}).then((data) => {
    str += data;
    return p3;
}, (error) => {
    console.log(error);
}).then((data) => {
    str += data;
    console.log(str);
}, (error) => {
    console.log(error);
})